using System.Xml;

namespace GSN.Config
{
    public class XmlPasswordWriter
    {
        private XmlWriter _w = null;
        private bool _encrypt = false;

        public XmlPasswordWriter(XmlWriter w, bool encrypt)
        {
            _w = w;
            _encrypt = encrypt;
        }

        public void WriteElementString(string localName, string value)
        {
            _w.WriteElementString(localName, value);
        }

        public void WritePasswordElementString(string localName, string value)
        {
            string valueToWrite = value;

            if (_encrypt)
                valueToWrite = GSN.CryptUtils.encrypt(value);

            _w.WriteElementString(localName, valueToWrite);
        }
    }
}
